import * as apiService from '@/services/api';

/**
 * 获取会员层级列表
 * @returns {*} Promise
 *
 */
export function getUserLevelList({
  levelType,
} = {}) {
  return apiService.post('/gl/manage/user/level/list',{
    levelType,
  });
}

/**
 * 新增/修改会员层级
 * @param {number} levelId 层级IDs
 * @param {number} levelType 用户类型(0-会员、1-代理)
 * @param {number} sortId 排序序号，由 1开始升序排 列
 * @param {string} name 层级名称
 * @param {number} regFromTime 注册开始时间a
 * @param {number} regEndTime 注册截止时间
 * @param {number} rechargeTimes 充值次数
 * @param {number} rechargeTotal 充值总额
 * @param {number} withdrawTimes 提现次数
 * @param {number} betTotal 有效投注
 * @param {string} remark 备注
 * @returns {*} Promise
 *
 */
export const editUserLevel = ({
  levelId,
  levelType,
  sortId,
  name,
  regFromTime,
  regEndTime,
  rechargeTimes,
  rechargeTotal,
  withdrawTimes,
  betTotal,
  remark,
} = {}) => {
  if (!levelId) {
    return apiService.post('/gl/manage/user/level/add', {
      levelType,
      sortId,
      name,
      regFromTime,
      regEndTime,
      rechargeTimes,
      rechargeTotal,
      withdrawTimes,
      betTotal,
      remark,
    });
  }
  return apiService.post('/gl/manage/user/level/update', {
    levelId,
    name,
    regFromTime,
    regEndTime,
    rechargeTimes,
    rechargeTotal,
    withdrawTimes,
    betTotal,
    remark,
    sortId,
    levelType,
  });
};

/**
 * 获取层级锁定会员
 * @param {string} levelId 层级ID
 * @returns {*} Promise
 *
 */
export const getUserLevelMembers = ({
  levelId,
} = {}) => apiService.post('/gl/manage/user/level/detail/lock', {
  levelId,
});

/**
 * 获取用户所在层级的接口
 * @param {string} username 用户名
 * @returns {*} Promise
 *
 */
export const getUserLevelDetail = ({
  username,
} = {}) => apiService.post('/gl/manage/user/level/detail', {
  username,
});

/**
 * 删除会员层级
 * @param {number} levelId 层级ID
 * @returns {*} Promise
 *
 */
export const delUserLevel = ({
  levelId,
} = {}) => apiService.post('/gl/manage/user/level/delete', {
  levelId,
});

/**
 * 锁定会员层级
 * @param {string} levelId 层级ID
 * @param {string} username 用户名
 * @returns {*} Promise
 *
 */
export const lockUserLevel = ({
  levelId,
  username,
} = {}) => apiService.post('/gl/manage/user/level/lock', {
  levelId,
  username,
});

/**
 * 解锁会员层级
 * @param {string} username 用户名
 * @returns {*} Promise
 *
 */
export const unlockUserLevel = ({
  username,
} = {}) => apiService.post('/gl/manage/user/level/unlock', {
  username,
});
